#!/sbin/openrc-run

# fallback values for /etc/conf.d/nzbget
: ${command_user:=nzbget:nzbget}
: ${directory:=/var/lib/nzbget}
: ${configfile:=$directory/nzbget.conf}
: ${webdir:=/usr/share/webapps/nzbget}

name=nzbget
description="nzbget daemon"
command="/usr/bin/nzbget"
command_args="
	--server
	--configfile $configfile
	--option WebDir=$webdir
	--option ConfigTemplate=/usr/share/nzbget/nzbget.conf
	--option WriteLog=none
	$command_args"
command_background=true
pidfile="/run/$name.pid"

depend() {
	need net
	use dns logger netmount
}

start_pre() {
	checkpath -d -o "$command_user" "$directory"
	checkpath -f -o "$command_user" "$configfile"

	if [ -n "$output_log" ]; then
		checkpath -f -o "$command_user" "$output_log"
	fi

	if [ -n "$error_log" ]; then
		checkpath -f -o "$command_user" "$error_log"
	fi
}
